package com.yexuejc.vertx.todolist.service;

import com.yexuejc.base.http.Resps;
import com.yexuejc.vertx.todolist.verticle.DBVerticle;
import io.vertx.ext.asyncsql.AsyncSQLClient;

import java.util.HashMap;
import java.util.Map;

/**
 * @PackageName: com.yexuejc.vertx.todolist.service
 * @Description:
 * @author: maxf
 * @date: 2018/4/12 18:05
 */
public class TodoSrvImpl implements TodoSrv {
    public TodoSrvImpl(AsyncSQLClient client) {
        this.dbVerticle = new DBVerticle(client);
    }

    private DBVerticle dbVerticle;

    @Override
    public void getTodo(Object body, Callback callback) {
        Map<String, Object> map = new HashMap<>();
        dbVerticle.getUser((list, count) -> {
            map.put("list", list);
            map.put("count", count);
            callback.result(Resps.success().setSucc(map));
        });
    }
}
